package org.willthink.service.fileupload.impl;

import java.util.ArrayList;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.willthink.common.PagingProcessUtil;
import org.willthink.dao.fileupload.FileUploadDAO;
import org.willthink.service.fileupload.FileUploadService;
import org.willthink.vo.common.PagingValuesVo;
import org.willthink.vo.fileupload.FileUploadInfoVo;

@Service//("fileUploadService")
public class FileUploadServiceImpl implements FileUploadService {
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	private FileUploadDAO fileUploadDAOImpl;
	
	public void setFileUploadDAOImpl(FileUploadDAO fileUploadDAOImpl) {
		this.fileUploadDAOImpl = fileUploadDAOImpl;
	}

	@Override
	public void uploadFilesDbInsert(FileUploadInfoVo fileUploadInfoVo) {
		// logger.debug(" : {}", );
		logger.debug("FileUploadServiceImpl fileUploadInfoVo : {}", fileUploadInfoVo);
		logger.debug("FileUploadServiceImpl fileUploadDAOImpl : {}", fileUploadDAOImpl);
		fileUploadDAOImpl.uplaodFilesDbInsert(fileUploadInfoVo);
	}
	
	@Override
	public ArrayList<FileUploadInfoVo> getUploadFileList(int firstRow, int endRow) {
		
		String strFirstRow = firstRow + "";
		String strEndRow = endRow + "";
		
		ArrayList<FileUploadInfoVo> selectFileList = null;
		
		selectFileList = fileUploadDAOImpl.getUploadFileList(strFirstRow, strEndRow);
		logger.debug("FileUploadServiceImpl selectFileList : {}", selectFileList);
		return selectFileList;
		
	}

	@Override
	public int getUploadFileAllRow() {
		
		logger.debug("FileUploadServiceImpl getUploadFileAllRow()");
		int selectUploadFileAllRowCnt = 0; 
		selectUploadFileAllRowCnt = fileUploadDAOImpl.getUploadFileAllRow();
		logger.debug("FileUploadServiceImpl selectUploadFileAllRowCnt : {}", selectUploadFileAllRowCnt);
		return selectUploadFileAllRowCnt;
		
	}

	@Override
	public ArrayList<FileUploadInfoVo> getSearchFileList(String fileName) {
		ArrayList<FileUploadInfoVo> selectFileList = null;
		selectFileList = fileUploadDAOImpl.getSearchFileList(fileName);
		logger.debug("FileUploadServiceImpl selectFileList : {}", selectFileList);
		return selectFileList;
	}

	@Override
	public void deleteFile(int deleteNo) {
		logger.debug("FileUploadServiceImpl deleteNo : {}", deleteNo);
		fileUploadDAOImpl.deleteFile(deleteNo);
		
	}

	@Override
	public String getDeleteFileName(int no) {
		logger.debug("FileUploadServiceImpl no : {}", no);
		String deleteFileName = fileUploadDAOImpl.getDeleteFileName(no);
		logger.debug("FileUploadServiceImpl deleteFileName : {}", deleteFileName);
		return deleteFileName;
	}

	
	

}
